home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / GRAHAM / XA_6S.ZIP / SOURCE / TASKMAN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-23  |  3.6 KB  |  164 lines

  1. /*
  2.  * XaAES - XaAES Ain't the AES
  3.  *
  4.  * A multitasking AES replacement for MiNT
  5.  *
  6.  */
  7.  
  8. #include <OSBIND.H>
  9. #include <MINTBIND.H>
  10. #include <SIGNAL.H>
  11. #include <VDI.H>
  12. #include <stdio.h>
  13. #include "XA_TYPES.H"
  14. #include "XA_CODES.H"
  15. #include "XA_DEFS.H"
  16. #include "XA_GLOBL.H"
  17. #include "OBJECTS.H"
  18. #include "FRM_ALRT.H"
  19. #include "FSELECT.H"
  20. #include "STD_WIDG.H"
  21. #include "C_WINDOW.H"
  22. #include "SYSTEM.H"
  23. #include "RESOURCE.H"
  24. #include "SCRLOBJC.H"
  25. #include "K_DEFS.H"
  26. #include "shellwrt.h"
  27.  
  28. void refresh_tasklist(OBJECT *form)
  29. {
  30.     XA_CLIENT *client;
  31.     SCROLL_ENTRY entry;
  32.     short cpid;
  33.  
  34. /* Empty the task list */
  35.     empty_scroll_list(form, TM_LIST);
  36.  
  37. /* Add all current tasks to the list */
  38.     for(client=FirstClient(); client; client=NextClient(client) )
  39.     {
  40.         entry.text=client->name;
  41.         if (client->msg)
  42.         {
  43.             entry.icon=form+TM_ICN_MESSAGE;
  44.         }else{
  45.             cpid=Client2Pid(client);
  46.             if ((cpid==mouse_lock)||(cpid==update_lock))
  47.             {
  48.                 entry.icon=form+TM_ICN_LOCK;
  49.             }else{
  50.                 if (client->client_type==XA_CT_ACC)
  51.                 {
  52.                     entry.icon=form+TM_ICN_MENU;
  53.                 }else{
  54.                     entry.icon=form+TM_ICN_XAAES;
  55.                 }
  56.             }
  57.         }
  58.         add_scroll_entry(form, TM_LIST, &entry);
  59.     }
  60. }
  61.  
  62. void handle_taskmanager(ODC_PARM *odc_p)
  63. {
  64.     SCROLL_INFO *list;
  65.     SCROLL_ENTRY *this;
  66.     OBJECT *ob=odc_p->tree+TM_LIST;
  67.     XA_CLIENT *client;
  68.     
  69.     list=(SCROLL_INFO*)ob->ob_spec;
  70.     
  71.     switch(odc_p->object)
  72.     {
  73.         case TM_KILL:
  74.             client=FirstClient(); this=list->scrl_start;
  75.             
  76.             while(this!=list->scrl_current)
  77.             {
  78.                 this=this->next;
  79.                 client=NextClient(client);
  80.             }
  81.             
  82.             Pkill(Client2Pid(client),SIGKILL);
  83.  
  84.             Fselect(200,NULL,NULL,NULL);
  85.  
  86.             refresh_tasklist(odc_p->tree);
  87.  
  88.             v_hide_c(V_handle);
  89.             draw_object_tree(odc_p->tree,TM_LIST,1);
  90.             v_show_c(V_handle,1);
  91.             
  92.             break;
  93.     }
  94. }
  95.  
  96. void open_taskmanager(void)
  97. {
  98.     XA_WINDOW *dialog_window;
  99.     OBJECT *form=ResourceTree(system_resources,TASK_MANAGER);
  100.     XA_WIDGET_LOCATION dialog_toolbar_loc={LT,3,0};
  101.     short x,y,w,h;
  102.     
  103.     dialog_toolbar_loc.y=display.c_max_h+1;
  104.     
  105.     form->ob_x=(display.w-form->ob_width)/2;
  106.     form->ob_y=(display.h-form->ob_height)/2;
  107.  
  108.     refresh_tasklist(form);
  109.  
  110. /* Create a temporary window to work out sizing */
  111.     dialog_window=create_window(AESpid, CLOSE|NAME|MOVE, form->ob_x, form->ob_y, form->ob_width, form->ob_height);
  112.  
  113.     x=2*dialog_window->x - dialog_window->wx;
  114.     y=2*dialog_window->y - dialog_window->wy;
  115.     w=2*dialog_window->w - dialog_window->ww +1;
  116.     h=2*dialog_window->h - dialog_window->wh +1;
  117.  
  118. /* Dispose of the temporary window we created */
  119.     delete_window(dialog_window);
  120.  
  121. /* Now create the real window */
  122.     dialog_window=create_window(AESpid, CLOSE|NAME|MOVE|NO_MESSAGES|NO_WORK, x, y, w, h);
  123.  
  124.     dialog_window->created_by_FMD_START=FALSE;
  125.  
  126. /* Set the window title */
  127.     dialog_window->widgets[XAW_TITLE].stuff="Task Manager";
  128.  
  129.     dialog_toolbar_loc.y=display.c_max_h+10;
  130.     set_toolbar_widget(dialog_window, dialog_toolbar_loc, form);
  131.     
  132.     ((XA_WIDGET_TREE*)dialog_window->widgets[XAW_TOOLBAR].stuff)->owner=AESpid;
  133.     ((XA_WIDGET_TREE*)dialog_window->widgets[XAW_TOOLBAR].stuff)->handler=&handle_taskmanager;
  134.     
  135.     dialog_window->is_open=TRUE;
  136.  
  137.     v_hide_c(V_handle);
  138.     pull_wind_to_top(dialog_window);
  139.     display_window(dialog_window);
  140.     v_show_c(V_handle,1);
  141. }
  142.  
  143. void handle_launcher(char *path,char *file)
  144. {
  145.     char parms[200],*t;
  146.     
  147.     sprintf(parms+1,"%s\\%s",path,file);
  148.     parms[0]='\0';
  149.     for(t=parms+1; *t; t++)
  150.     {
  151.         if(*t=='/')
  152.             *t='\\';
  153.     }        
  154.  
  155.     DIAGS(("launch:%s\n",parms+1));
  156.  
  157.     shell_write(0,0,0,parms+1,parms);
  158. }
  159.  
  160. void open_launcher(void)
  161. {
  162.     open_fileselector("u:/*","Launch Program",&handle_launcher,NULL);
  163. }
  164.